home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / edit / mg2a_src.zip / TUTORIAL < prev    next >
Text File  |  1988-08-23  |  25KB  |  605 lines

  1. Copyright (c) 1985 Richard M. Stallman.  See end for copying conditions.
  2.  
  3. You are looking at the Emacs tutorial.
  4.  
  5. Emacs commands generally involve the CONTROL key or the META (ESC)
  6. key.  Rather than write out META or CONTROL each time we want you to
  7. prefix a character, we'll use the following abbreviations:
  8.  
  9.  C-<chr>  means hold the CONTROL key while typing the character <chr>
  10.       Thus, C-f would be: hold the CONTROL key and type f.
  11.  M-<chr>  means type <ESC>, release it, then type the character <chr>.
  12.  
  13. The characters ">>" at the left margin indicate directions for you to
  14. try using a command.  For instance:
  15.  
  16. >>  Now type C-v (View next screen) to move to the next screen.
  17.     (go ahead, do it by depressing the control key and v together).
  18.     From now on, you'll be expected to do this whenever you finish
  19.     reading the screen.
  20.  
  21. Note that there is an overlap when going from screen to screen; this
  22. provides some continuity when moving through the file.
  23.  
  24. The first thing that you need to know is how to move around from
  25. place to place in the file.  You already know how to move forward a
  26. screen, with C-v.  To move backwards a screen, type M-v (type <ESC>v).
  27.  
  28. >>  Try typing M-v and then C-v to move back and forth a few times.
  29.  
  30.  
  31. SUMMARY
  32. -------
  33.  
  34. The following commands are useful for viewing screenfuls:
  35.  
  36.     C-v    Move forward one screenful
  37.     M-v    Move backward one screenful
  38.     C-l    Clear screen and redisplay everything
  39.          putting the text near the cursor at the center.
  40.          (That's control-L, not control-1.
  41.           There is no such character as control-1.)
  42.  
  43. >> Find the cursor and remember what text is near it.
  44.    Then type a C-l.
  45.    Find the cursor again and see what text is near it now.
  46.  
  47.  
  48. BASIC CURSOR CONTROL
  49. --------------------
  50.  
  51. Getting from screenful to screenful is useful, but how do you
  52. reposition yourself within a given screen to a specific place?  There
  53. are several ways you can do this.  One way (not the best, but the most
  54. basic) is to use the commands previous, backward, forward and next.
  55. As you can imagine these commands (which are given to Emacs as C-p,
  56. C-b, C-f, and C-n respectively) move the cursor from where it
  57. currently is to a new place in the given direction.  It is also
  58. possible to move the cursor with the arrow keys, but this requires you
  59. move your hand from the keyboard, it is also not supported on other
  60. machines that do support Emacs.  Emacs runs on everything from a CP/M
  61. machine to large mainframes. Here then, in a more graphical form are
  62. the commands:
  63.  
  64.               Previous line, C-p
  65.                   :
  66.                   :
  67.    Backward, C-b .... Current cursor position .... Forward, C-f
  68.                   :
  69.                   :
  70.               Next line, C-n
  71.  
  72. >> Move the cursor to the line in the middle of that diagram
  73.    and type C-l to see the whole diagram centered in the screen.
  74.  
  75. You'll probably find it easy to think of these by letter.  P for
  76. previous, N for next, B for backward and F for forward.  These are
  77. the basic cursor positioning commands and you'll be using them ALL
  78. the time so it would be of great benefit if you learn them now.
  79.  
  80. >> Do a few C-n's to bring the cursor down to this line.
  81.  
  82. >> Move into the line with C-f's and then up with C-p's.
  83.    See what C-p does when the cursor is in the middle of the line.
  84.  
  85. >> Try to C-b at the beginning of a line.  Do a few more C-b's.
  86.    Then do C-f's back to the end of the line and beyond.
  87.  
  88. When you go off the top or bottom of the screen, the text beyond
  89. the edge is shifted onto the screen so that your instructions can
  90. be carried out while keeping the cursor on the screen.
  91.  
  92. >> Try to move the cursor off the bottom of the screen with C-n and
  93.    see what happens.
  94.  
  95. If moving by characters is too slow, you can move by words.  M-f
  96. (ESC-f) moves forward a word and M-b moves back a word.
  97.  
  98. >> Type a few M-f's and M-b's.  Intersperse them with C-f's and C-b's.
  99.  
  100. Notice the parallel between C-f and C-b on the one hand, and M-f and
  101. M-b on the other hand.  Very often Meta characters are used for
  102. operations related to English text whereas Control characters operate
  103. on the basic textual units that are independent of what you are
  104. editing (characters, lines, etc). C-a and C-e move to the beginning or
  105. end of a line.
  106.  
  107. >> Try a couple of C-a's, and then a couple of C-e's.
  108.    See how repeated C-a's do nothing.
  109.  
  110. Two other simple cursor motion commands are M-< (Meta Less-than),
  111. which moves to the beginning of the file, and M-> (Meta Greater-than),
  112. which moves to the end of the file.  You probably don't need to try
  113. them, since finding this spot again will be boring.  On most terminals
  114. the "<" is above the comma and you must use the shift key to type it.
  115. On these terminals you must use the shift key to type M-< also;
  116. without the shift key, you would be typing M-comma.
  117.  
  118. The location of the cursor in the text is also called "point".  To
  119. paraphrase, the cursor shows on the screen where point is located in
  120. the text.
  121.  
  122. Here is a summary of simple moving operations including the word and
  123. sentence moving commands:
  124.  
  125.     C-f    Move forward a character
  126.     C-b    Move backward a character
  127.  
  128.     M-f    Move forward a word
  129.     M-b    Move backward a word
  130.  
  131.     c-n    Move to next line
  132.     C-p    Move to previous line
  133.  
  134.     C-a    Move to beginning of line
  135.     C-e    Move to end of line
  136.  
  137.     M-<    Go to beginning of file
  138.     M->    Go to end of file
  139.  
  140. >> Try all of these commands now a few times for practice.
  141.    Since the last two will take you away from this screen,
  142.    you can come back here with M-v's and C-v's.  These are
  143.    the most often used commands.
  144.  
  145. Like all other commands in Emacs, these commands can be given
  146. arguments which cause them to be executed repeatedly.  The way you
  147. give a command a repeat count is by typing C-u and then the digits
  148. before you type the command.  
  149.  
  150. For instance, C-u 8 C-f moves forward eight characters.
  151.     
  152. >> Try giving a suitable argument to C-n or C-p to come as close
  153.    as you can to this line in one jump.
  154.  
  155. The only apparent exception to this is the screen moving commands,
  156. C-v and M-v.  When given an argument, they scroll the screen up or
  157. down by that many lines, rather than screenfuls.  This proves to be
  158. much more useful.
  159.  
  160. >> Try typing C-u 8 C-v now.
  161.  
  162. Did it scroll the screen up by 8 lines?  If you would like to
  163. scroll it down you can give an argument to M-v.
  164.  
  165.  
  166. WHEN EMACS IS HUNG
  167. -----------------
  168.  
  169. If Emacs gets into an infinite (or simply very long) computation which
  170. you don't want to finish, you can stop it safely by typing C-g.
  171. You can also use C-g to discard a numeric argument or the beginning of
  172. a command that you don't want to finish.
  173.  
  174. >> Type C-u 100 to make a numeric arg of 100, then type C-g.
  175.    Now type C-f.  How many characters does it move?
  176.    If you have typed an <ESC> by mistake, you can get rid of it
  177.    with a C-g.
  178.  
  179. WINDOWS
  180. -------
  181.  
  182. Emacs can have several windows, each displaying its own text.
  183. At this stage it is better not to go into the techniques of
  184. using multiple windows.  But you do need to know how to get
  185. rid of extra windows that may appear to display help or
  186. output from certain commands.  It is simple:
  187.  
  188.     C-x 1    One window (i.e., kill all other windows).
  189.  
  190. That is Control-x followed by the digit 1.
  191. C-x 1 makes the window which the cursor is in become
  192. the full screen, by getting rid of any other windows.
  193.  
  194. >> Move the cursor to this line and type C-l (Control-L).
  195. >> Type M-x. The cursor will move to the bottom of the screen.
  196. >> Type the words "describe-bindings" and hit return.
  197.    See how this window shrinks, while a new one appears
  198.    to display which functions are connected to which keys.
  199.  
  200. >> Type C-x 1 and see the documentation listing window disappear.
  201.  
  202.  
  203. INSERTING AND DELETING
  204. ----------------------
  205.  
  206. If you want to insert text, just type it.  Characters which you can
  207. see, such as A, 7, *, etc. are taken by Emacs as text and inserted
  208. immediately.  Type <Return> (the carriage-return key) to insert a
  209. Newline character.
  210.  
  211. You can delete the last character you typed by typing <DEL>.  More
  212. generally, <DEL> deletes the character immediately before the current
  213. cursor position.
  214.  
  215. >> Do this now, type a few